package com.ljf.framework.exception;

import com.ljf.framework.result.JsonResultEnum;

/**
 * 说明：异常基类
 *
 * @Auther: lijinfeng
 * @Date: 2023/9/18
 */
public class LjfException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码 -1 标识这个异常在抛出时未指定异常细分状态码
     */
    private Integer code = -1;
    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     */
    private String detailMessage;

    public LjfException() {
    }

    public LjfException(String message) {
        this.message = message;
    }

    public LjfException(Integer code, String message) {
        this.message = message;
        this.code = code;
    }

    public LjfException(JsonResultEnum jsonResultEnum, String message) {
        this.code = jsonResultEnum.getCode();
        this.message = jsonResultEnum.getMessage();
        this.detailMessage = message;
    }

    public LjfException(JsonResultEnum jsonResultEnum) {
        this.code = jsonResultEnum.getCode();
        this.message = jsonResultEnum.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public LjfException setCode(Integer code) {
        this.code = code;
        return this;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public LjfException setMessage(String message) {
        this.message = message;
        return this;
    }

    public String getDetailMessage() {
        return detailMessage;
    }

    public LjfException setDetailMessage(String detailMessage) {
        this.detailMessage = detailMessage;
        return this;
    }



}
